package com.ruoyi.gams.controller;

import java.util.List;

import com.ruoyi.gams.vo.GamsDeviceBussinessRelationAddParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gams.domain.GamsWindowScreen;
import com.ruoyi.gams.service.IGamsWindowScreenService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 窗口屏Controller
 *
 * @author ruoyi
 */
@Api(tags = "广告系统后台：窗口屏")
@RestController
@RequestMapping("/gams/screen")
public class GamsWindowScreenController extends BaseController
{
    @Autowired
    private IGamsWindowScreenService gamsWindowScreenService;

    /**
     * 查询窗口屏列表
     */
    @ApiOperation("查询窗口屏列表")
    @PreAuthorize("@ss.hasPermi('gams:screen:list')")
    @GetMapping("/list")
    public TableDataInfo list(GamsWindowScreen gamsWindowScreen)
    {
        startPage();
        List<GamsWindowScreen> list = gamsWindowScreenService.selectGamsWindowScreenList(gamsWindowScreen);
        return getDataTable(list);
    }

    /**
     * 导出窗口屏列表
     */
    @ApiOperation("导出窗口屏列表")
    @PreAuthorize("@ss.hasPermi('gams:screen:export')")
    @Log(title = "导出窗口屏列表" , businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GamsWindowScreen gamsWindowScreen)
    {
        List<GamsWindowScreen> list = gamsWindowScreenService.selectGamsWindowScreenList(gamsWindowScreen);
        ExcelUtil<GamsWindowScreen> util = new ExcelUtil<>(GamsWindowScreen.class);
        return util.exportExcel(list, "窗口屏数据");
    }

    /**
     * 获取窗口屏详细信息
     */
    @ApiOperation("获取窗口屏详细信息")
    @PreAuthorize("@ss.hasPermi('gams:screen:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gamsWindowScreenService.selectGamsWindowScreenById(id));
    }

    /**
     * 新增窗口屏
     */
    @ApiOperation("新增窗口屏")
    @PreAuthorize("@ss.hasPermi('gams:screen:add')")
    @Log(title = "新增窗口屏" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GamsWindowScreen gamsWindowScreen)
    {
        return toAjax(gamsWindowScreenService.insertGamsWindowScreen(gamsWindowScreen));
    }

    /**
     * 修改窗口屏
     */
    @ApiOperation("修改窗口屏")
    @PreAuthorize("@ss.hasPermi('gams:screen:edit')")
    @Log(title = "修改窗口屏" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GamsWindowScreen gamsWindowScreen)
    {
        return toAjax(gamsWindowScreenService.updateGamsWindowScreen(gamsWindowScreen));
    }

    /**
     * 删除窗口屏
     */
    @ApiOperation("删除窗口屏")
    @PreAuthorize("@ss.hasPermi('gams:screen:remove')")
    @Log(title = "删除窗口屏" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gamsWindowScreenService.deleteGamsWindowScreenByIds(ids));
    }
}
